<?php
namespace Article\Widget;

class ShowWidget extends \Common\Controller\BaseController {

	//参数说明   $tid   内容类别   $limit   显示条数    $type  显示方式
	public function run($tid,$limit,$type){
		if ($tid) {
			$map['cateid']  = $tid;
		}
		$map['isrecommend'] = 1;
		if ($type == 2) {
			$map['photo'] = array('neq','');
		}

		$row = D('Article')->where($map)->limit($limit)->order('addtime desc')->select();
		foreach ($row as $key => $value) {
			$value['photo'] = $value['photo'] ? $value['photo'] : './Public/Static/images/dot.png';
			$value['instro'] = msubstr(tt($value['content']),0,200);
			if ($type == 3) {
				if ($key == 0) {
					$top[] = $value;
				}else{
					$list[] = $value;
				}
			}else{
				$list[] = $value;
			}
		}
		$data = array(
			'list'  => $list,
			'top'   => $top,
			'type'  => $type,
		);
		$this->assign($data);
		$this->template('Article@Widget/show');
	}
}